package com.example.svntest;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
	
	static void D(String msg) {
		Log.d("MyService", msg);
	}
	
	public void myMethod() {
		D("myMethod()");
	}

	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		D("onCreate()");
		super.onCreate();
	}

	@Override
	public void onStart(Intent intent, int startId) {
		// TODO Auto-generated method stub
		D("onStart()");
		super.onStart(intent, startId);
		
		Notification notification = new Notification(R.drawable.ic_launcher,
				"a notification", //getText(R.string.ticker_text),
		        System.currentTimeMillis());
		Intent notificationIntent = new Intent(this, Activity2.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
		notification.setLatestEventInfo(this, "title",
		        "text", pendingIntent);
		startForeground(123, notification);
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		// TODO Auto-generated method stub
		D("onStartCommand()");
		return super.onStartCommand(intent, flags, startId);
	}

	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		D("onDestroy()");
		stopForeground(true);
		super.onDestroy();
	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		// TODO Auto-generated method stub
		D("onConfigurationChanged()");
		super.onConfigurationChanged(newConfig);
	}

	@Override
	public void onLowMemory() {
		// TODO Auto-generated method stub
		D("onLowMemory()");
		super.onLowMemory();
	}

	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		D("onBind()");
		return new Binder() {
			
			public void myFun() {
				System.out.println("myFun");
			}

			public void myMethod() {
				System.out.println("myMethod");
			}
		};
	}

	@Override
	public boolean onUnbind(Intent intent) {
		// TODO Auto-generated method stub
		D("onUnbind()");
		return super.onUnbind(intent);
	}

	@Override
	public void onRebind(Intent intent) {
		// TODO Auto-generated method stub
		D("onRebind()");
		super.onRebind(intent);
	}


}
